<div class="flex justify-center items-center min-h-screen bg-base-200">
  <div class="card w-96 bg-base-100 shadow-xl">
    <div class="card-body">
      <div>
        <h1 class="text-2xl font-bold text-center mb-0">
          Log in to <%= @account.name %>
        </h1>
        <div class="flex justify-center mt-3">
          <%= render "devise/sessions/portainer_badge", stack_manager: @account.stack_manager %>
        </div>
      </div>
      <p class="text-center text-sm text-gray-500 mt-2">
        Sign in to access your account
      </p>

      <%= form_with(
        model: resource,
        as: resource_name,
        url: account_sign_in_path(@account.slug),
        method: :post,
        data: { turbo: false },
        html: { class: "space-y-4" }) do |f|
      %>
        <% if flash[:alert] %>
          <div class="alert alert-error mb-4">
            <iconify-icon icon="lucide:alert-triangle" class="mr-2 text-white"></iconify-icon>
            <span><%= flash[:alert] %></span>
          </div>
        <% end %>

        <%= render 'shared/error_messages', resource: resource %>

        <div class="form-control">
          <%= f.label :username, class: "label" do %>
            <span class="label-text">Portainer Username</span>
          <% end %>
          <%= f.text_field(
            :username,
            autofocus: true,
            placeholder: "Enter your username",
            class: "input input-bordered w-full",
            required: true,
          ) %>
        </div>

        <div class="form-control">
          <%= f.label :password, class: "label" do %>
            <span class="label-text">Portainer Password</span>
          <% end %>
          <%= f.password_field(
            :password,
            autocomplete: "current-password",
            placeholder: "Enter your password",
            class: "input input-bordered w-full",
            required: true,
          ) %>
        </div>

        <div class="form-control mt-6">
          <%= f.submit "Sign in to #{@account.name}", class: "btn btn-primary w-full" %>
        </div>
      <% end %>

      <div class="divider">New to <%= @account.name %>?</div>

      <p class="text-center text-sm">
        Contact your account administrator to get access
      </p>

      <div class="mt-4 text-center">
        <%= link_to "Back to main login", new_user_session_path, class: "link link-primary text-sm" %>
      </div>
    </div>
  </div>
</div>